package be.myandroid.games;

public class ExpandingCircle extends MovingCircle{
	
	public static float MAXSIZE = 0.4f;
	private static final float rate = 0.005f;
	public static int MAX_TIME = 100;
	private int elapsedTime = 0;
	
	public boolean isHit(float[] pos){
		double[] diff = {pos[X]-this.pos[X], pos[Y]-this.pos[Y]};
		if(diff[0] > size + SIZE || diff[1] > size + SIZE)
			return false;
		double radius = Math.pow(diff[X],2) + Math.pow(diff[Y], 2);
		return radius - SIZE / 2 < Math.pow(size, 2);
	}
	
	public void expand(int duration) {
		this.elapsedTime += duration;
		
		if(size < MAXSIZE)
			size+=rate;
	}

	public boolean removed() {
		return elapsedTime > MAX_TIME;
	}

}
